<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * For example, it puts together the home page when no home.php file exists.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @since 3.0.0
 */
get_header(); ?>
<?php if(is_home()): ?>
<div id="vos_primary" role="main">
	<div id="vos_top3" class="item1">
		<div class="home_title">THANH VÂN GALLERY</div>
		<div class="home_content"><img src="wp-content/themes/magazine-basic/library/images/support.gif" /></div>
	</div>
	<div id="vos_top4" class="item1">
		<div class="home_title">ÁO CƯỚI THANH VÂN</div>
		<div class="home_content">
			<div class="vos_top4_l">
				<ul class="vos_top4_ul">
					<li></li>
				</ul>
			</div>
			<div class="vos_top4_r">
				<?php
						if ( is_active_sidebar( 'home_promotion' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_promotion' ); ?></center>
							</div>
							<?php
						}
						?>	
			</div>
			<div style="clear:both;"></div>
		</div>
	</div>
	<div id="vos_top5" class="item1">
		<div class="home_title">DỊCH VỤ CỦA ÁO CƯỚI THANH VÂN</div>
		<div class="home_content">
			<div>
				<ul class="vos_top5_top">
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t1' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t1' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t2' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t2' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t3' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t3' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t4' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t4' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t5' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t5' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t6' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t6' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t7' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t7' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
					<li>
						<?php
						if ( is_active_sidebar( 'home_service_t8' ) ) { ?>
							<div id="home_service_t" class="<?php echo $header_class; ?>">
								<center><?php dynamic_sidebar( 'home_service_t8' ); ?></center>
							</div>
							<?php
						}
						?>	
						 
					</li>
				</ul>
			</div>
			<div style="clear:both;"></div>
			<div class="vos_top5_bottom">
				<?php
				if ( is_active_sidebar( 'home_service' ) ) { ?>
					<div id="home_service" class="<?php echo $header_class; ?>">
						<center><?php dynamic_sidebar( 'home_service' ); ?></center>
					</div>
					<?php
				}
				?>	
			</div>
		</div>
	</div>
	<div id="vos_top6" class="item1">
		<div class="left">
			<div class="home_title">BÀI VIẾT MỚI NHẤT</div>
			<div class="home_content">
				
			</div>
		</div>
		<div class="right">
			<div class="home_title_right"><img src="wp-content/themes/magazine-basic/library/images/ao-cuoi-thanh-van-poste.gif" alt="cảm nhận khách hàng về áo cưới thanh vân" /></div>
			<div class="home_content_right">
				
			</div>
			<div class="home_footer_right"><img src="wp-content/themes/magazine-basic/library/images/footer-poste.gif" alt="cảm nhận khách hàng về áo cưới thanh vân" /></div>
		</div>
		<div style="clear:both;"></div>
	</div>
	<div id="vos_top7" class="item1">
		<div class="home_title">HỎI ĐÁP</div>
		<div class="home_content"><img src="wp-content/themes/magazine-basic/library/images/support.gif" /></div>
	</div>
</div>
<?php else: ?>
	<div id="primary" <?php mb_primary_attr(); ?> role="main">
		<?php
		$sticky = get_option( 'sticky_posts' );
		$featured = new WP_Query( array(
			'posts_per_page' => 1,
			'post__in'  => $sticky,
			'ignore_sticky_posts' => 1
		) );
		global $paged;
		if ( ! empty( $sticky[0] ) && is_home() && 2 > $paged ) 
		{
			?>
			<div id="featured" class="row">
				<?php
				while ( $featured->have_posts() ) : $featured->the_post();
			    	global $mb_content_area;
			    	$mb_content_area = 'main';
					get_template_part( 'content', get_post_format() );
				endwhile;
	
				wp_reset_postdata();
				?>
			</div>
		<?php
		}

		if ( have_posts() ) : ?>
			<div class="row">
			<?php
			while ( have_posts() ) : the_post();
				global $wp_query;
				$paged = ( get_query_var( 'paged' ) ) ? get_query_var('paged') : 1;
				$grid = mb_theme_options( 'grid' );
				$posts_per_page = mb_theme_options( 'number' );
				$count = $wp_query->current_post;
				$total = $wp_query->post_count - 1;
				$border = ( 3 == $grid && 1 == $paged ) ? '<div class="c12 border"><span></span></div>' : '';

				$two_open_tag = ( ( ( 2 == $grid || 3 == $grid) && 1 == $count && 1 == $paged ) || ( 2 == $grid && 0 == $count && 1 < $paged ) ) ? '<div class="two-col-wrapper">' : '';
				$two_close_tag = ( ( 2 == $grid && $total == $count ) || ( 3 == $grid && 2 == $count && 1 == $paged ) ) ? '</div>' : '';
				$three_open_tag = ( ( 3 == $grid  && 3 == $count && 1 == $paged ) || ( 4 == $grid  && 1 == $count && 1 == $paged ) || ( ( 3 == $grid || 4 == $grid ) && 0 == $count && 1 < $paged ) ) ? $border . '<div class="three-col-wrapper">' : '';
				$three_close_tag = ( ( 3 == $grid || 4 == $grid ) && $total == $count ) ? '</div>' : '';

				if ( 1 < $posts_per_page ) {
					echo $two_open_tag;
					echo $three_open_tag;
				}

		    	global $mb_content_area;
		    	$mb_content_area = 'main';
		    	get_template_part( 'content', get_post_format() );

				if ( 1 < $posts_per_page ) {
					echo $two_close_tag;
					echo $three_close_tag;
				}
			endwhile;
			?>
			</div>
			<?php
			mb_pagination();

		else :
			?>
			<article id="post-0" class="post no-results not-found">

			<?php if ( current_user_can( 'edit_posts' ) ) :
				// Show a different message to a logged-in user who can add posts.
				?>
				<h1 class="entry-title"><?php _e( 'No posts to display', 'magazine-basic' ); ?></h1>

				<div class="entry-content">
					<p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'magazine-basic' ), admin_url( 'post-new.php' ) ); ?></p>
				</div><!-- .entry-content -->

				<?php
			else :
				get_template_part( 'content', 'none' );
			endif; // end current_user_can() check
			?>

			</article><!-- #post-0 -->
		    <?php

		endif;
		?>
	</div><!-- #primary.c8 -->
<?php endif; ?>
<?php get_footer(); ?>